import { request } from '@/utils/request.js'

export default {
  /**
   * 分頁查詢notifications列表
   * @param {object} params
   * @param {number} params.pageNum
   * @param {number} params.pageSize
   * @param {number} params.title
   * @param {string} params.type
   * @returns
   */
  getNotificationsList(params) {
    return request({
      url: '/api/v1/admin/notifications',
      method: 'get',
      params
    })
  },
  /**
   * 創建New
   * @param {object} data
   * @param {string} data.title
   * @param {string} data.content
   * @param {number} data.type
   * @param {number} data.targetType
   * @param {array} data.groupIds
   * @param {array} data.userIds
   * @param {string} data.sendTime
   * @param {string} data.templateId
   * @returns
   */
  createNotifications(data = {}) {
    return request({
      url: '/api/v1/admin/notifications',
      method: 'post',
      data
    })
  },
  /**
   * 根據ID獲取Notifications
   * @param {string} params
   * @returns
   */
  getNotificationsDetail(params) {
    return request({
      url: `/api/v1/admin/notifications/${params}`,
      method: 'get'
    })
  },
  /**
   * 刪除Notifications
   * @param {string} params
   * @returns
   */
  deleteNotifications(params) {
    return request({
      url: `/api/v1/admin/notifications/${params}`,
      method: 'delete'
    })
  },
  /**
   * 立即發送Notifications
   * @param {string} params
   * @returns
   */
  sendNotifications(params) {
    return request({
      url: `/api/v1/admin/notifications/${params}/send`,
      method: 'post'
    })
  }
}
